Installer le package {robis}

1- Le package {devtools} disponible sur le CRAN (dépôt de package R en ligne) doit être installé en premier pour permettre l’installation du package {robis} depuis GitHub (Sources: https://obis.org/manual/accessr/, https://iobis.github.io/robis/articles/getting-started.html). 2- Puisque nous en sommes à l’installation de package sur le CRAN, allons chercher tous les packages dont nous aurons besoin.

Lorsque {devtools} est installé, la fonction install_github() peut être utilisée pour installer {robis}:

Inclure {robis} et les autres packages que nous allons utiliser dans ce notebook

library(udunits2)
## udunits system database read from C:/Users/Cédric/Documents/R/win-library/4.0/udunits2/share/udunits/udunits2.xml
library(robis)
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Après avoir chargé {robis}, regardons sa documentation:

help(package = "robis")
?occurrence 
## starting httpd help server ... done

Aller chercher des occurrences

Aller chercher toutes les occurrences pour un taxon donné (par exemple Pterois volitans) grâce à la fonction occurence()

On peut chercher ces occurrences grâce au nom du taxon sous forme de vecteur:

ptevol <- occurrence("Pterois volitans")
## Retrieved 4007 records of approximately 4007 (100%)
View(ptevol)

On peut également chercher ces occurrences grâce au AphiaID:

taxid <- occurrence(taxonid = 293683)
## Retrieved 767 records of approximately 767 (100%)
View(taxid)
Appliquer un filtre de type polygone

La fonction occurence() accepte des paramètres géométriques qui peuvent être utilisés afin de filtrer les occurences en fonction de leur position géographique. Cet argument doit être formaté comme un WKT (well known text representation https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry). OBIS possède un outil cartographique qui facilite la création de chaîne de caractère WKT par un simple clique sur une carte (https://obis.org/maptool/).

Allons voir si nous avons des données en provenance des îles Perhentian et Redang:

islands <- occurrence(geometry = "POLYGON ((102.68921 6.05862, 102.57111 5.95346, 103.07785 5.49980, 103.25226 5.62555, 103.07648 5.87970, 102.68921 6.05862))")
## Retrieved 1422 records of approximately 1422 (100%)
View(islands)

La fonction map_leaflet() nous permet de créer une carte intéractive simple

map_leaflet(islands)
Appliquer un filtre de profondeur

On peut sélectionner les occurrences provenant d’une profondeur ou d’une classe de profondeur ciblée grâce aux paramètres startdepth et endepth. Par exemple, on peut retrouver les enregistrement les moins profonds d Hoplostèthes oranges (l hoplostèthe orange, revendu sous le nom empereur, est un poisson vivant dans la zone bathyale et est ciblé par la pêche industrielle) en tapant:

roughy_shallow <- occurrence("Hoplostethus atlanticus", enddepth = 400)
## Retrieved 71 records of approximately 71 (100%)
map_leaflet(roughy_shallow) 
Appliquer un filtre de date

De la même manière que pour la profondeur, on peut utiliser la date comme filtre avec les arguments startdate et enddate. /! Attention aux formats de date à utiliser (aaaa-mm-jj):

lionfish_native <- occurrence("Pterois volitans", enddate = "1980-01-01")
## Retrieved 280 records of approximately 280 (100%)
map_leaflet(lionfish_native)

Explorer les données d occurrences

Coup d’oeil rapide à votre jeu de données

La première chose à faire lors de l’exploration d un jeu de données est de vérifier ses colonnes:

names(islands)
##   [1] "country"                       "date_year"                    
##   [3] "habitat"                       "scientificNameID"             
##   [5] "scientificName"                "dropped"                      
##   [7] "aphiaID"                       "decimalLatitude"              
##   [9] "subclassid"                    "phylumid"                     
##  [11] "familyid"                      "occurrenceStatus"             
##  [13] "basisOfRecord"                 "modified"                     
##  [15] "maximumDepthInMeters"          "id"                           
##  [17] "order"                         "dataset_id"                   
##  [19] "locality"                      "decimalLongitude"             
##  [21] "date_end"                      "occurrenceID"                 
##  [23] "suborderid"                    "date_start"                   
##  [25] "eventDate"                     "eventID"                      
##  [27] "coordinateUncertaintyInMeters" "absence"                      
##  [29] "taxonRank"                     "marine"                       
##  [31] "minimumDepthInMeters"          "preparations"                 
##  [33] "institutionCode"               "date_mid"                     
##  [35] "class"                         "suborder"                     
##  [37] "orderid"                       "footprintWKT"                 
##  [39] "datasetName"                   "geodeticDatum"                
##  [41] "kingdom"                       "recordedBy"                   
##  [43] "disposition"                   "classid"                      
##  [45] "phylum"                        "subclass"                     
##  [47] "family"                        "kingdomid"                    
##  [49] "node_id"                       "flags"                        
##  [51] "sss"                           "depth"                        
##  [53] "shoredistance"                 "sst"                          
##  [55] "bathymetry"                    "rightsHolder"                 
##  [57] "type"                          "catalogNumber"                
##  [59] "terrestrial"                   "superclass"                   
##  [61] "recordNumber"                  "superclassid"                 
##  [63] "collectionCode"                "license"                      
##  [65] "genus"                         "collectionID"                 
##  [67] "brackish"                      "subfamily"                    
##  [69] "genusid"                       "originalScientificName"       
##  [71] "subphylumid"                   "subfamilyid"                  
##  [73] "subphylum"                     "references"                   
##  [75] "year"                          "day"                          
##  [77] "georeferenceRemarks"           "minimumElevationInMeters"     
##  [79] "speciesid"                     "maximumElevationInMeters"     
##  [81] "month"                         "samplingProtocol"             
##  [83] "continent"                     "scientificNameAuthorship"     
##  [85] "eventTime"                     "species"                      
##  [87] "datasetID"                     "specificEpithet"              
##  [89] "category"                      "individualCount"              
##  [91] "wrims"                         "superfamilyid"                
##  [93] "county"                        "language"                     
##  [95] "stateProvince"                 "superfamily"                  
##  [97] "footprintSRS"                  "bibliographicCitation"        
##  [99] "waterBody"                     "occurrenceRemarks"            
## [101] "dynamicProperties"             "associatedReferences"         
## [103] "subterclassid"                 "infraorderid"                 
## [105] "subterclass"                   "superorder"                   
## [107] "superorderid"                  "infraclassid"                 
## [109] "infraclass"                    "infraorder"                   
## [111] "vernacularName"                "section"                      
## [113] "subsection"                    "sectionid"                    
## [115] "subsectionid"                  "parvorder"                    
## [117] "typeStatus"                    "parvorderid"                  
## [119] "identifiedBy"                  "subgenus"                     
## [121] "subgenusid"                    "samplingEffort"               
## [123] "verbatimDepth"                 "organismQuantityType"         
## [125] "sex"                           "fieldNumber"                  
## [127] "otherCatalogNumbers"           "coordinatePrecision"          
## [129] "tribeid"                       "tribe"                        
## [131] "subkingdom"                    "infrakingdom"                 
## [133] "subkingdomid"                  "infrakingdomid"               
## [135] "taxonConceptID"                "organismQuantity"             
## [137] "endDayOfYear"                  "startDayOfYear"               
## [139] "subspecies"                    "subspeciesid"

Ensuite, utiliser table() pour créer une table de contingence afin de trouver quelles valeurs sont présentes dans certaines colonnes d’intérêt.

table(islands$phylum)
## 
##      Annelida    Arthropoda      Chordata      Cnidaria Echinodermata 
##            14            24           840           424            36 
##      Mollusca      Porifera  Tracheophyta 
##            56            15            13
table(islands$family, islands$phylum)
##                              
##                               Annelida Arthropoda Chordata Cnidaria
##   Acanthasteridae                    0          0        0        0
##   Acanthogorgiidae                   0          0        0        1
##   Acanthuridae                       0          0        2        0
##   Acroporidae                        0          0        0      174
##   Agariciidae                        0          0        0       28
##   Aglaopheniidae                     0          0        0        1
##   Alcyoniidae                        0          0        0       26
##   Ancorinidae                        0          0        0        0
##   Apogonidae                         0          0       65        0
##   Arcidae                            0          0        0        0
##   Ariommatidae                       0          0        1        0
##   Astrocoeniidae                     0          0        0        1
##   Astropectinidae                    0          0        0        0
##   Atherinidae                        0          0       25        0
##   Balistidae                         0          0        9        0
##   Belonidae                          0          0        2        0
##   Blenniidae                         0          0       28        0
##   Bopyridae                          0          1        0        0
##   Bothidae                           0          0        9        0
##   Caesionidae                        0          0        4        0
##   Calappidae                         0          1        0        0
##   Callionymidae                      0          0        3        0
##   Carangidae                         0          0       27        0
##   Carcharhinidae                     0          0        1        0
##   Centriscidae                       0          0        3        0
##   Centrolophidae                     0          0        2        0
##   Chaetodontidae                     0          0       15        0
##   Chalinidae                         0          0        0        0
##   Champsodontidae                    0          0        2        0
##   Cheloniidae                        0          0        4        0
##   Chilodontaidae                     0          0        0        0
##   Chirocentridae                     0          0        1        0
##   Cirratulidae                       1          0        0        0
##   Citharidae                         0          0        2        0
##   Clupeidae                          0          0        5        0
##   Conidae                            0          0        0        0
##   Cymodoceaceae                      0          0        0        0
##   Cynoglossidae                      0          0        2        0
##   Cypraeidae                         0          0        0        0
##   Dactylopteridae                    0          0        1        0
##   Dasyatidae                         0          0       13        0
##   Dendrophylliidae                   0          0        0        7
##   Desmacellidae                      0          0        0        0
##   Diadematidae                       0          0        0        0
##   Diodontidae                        0          0        5        0
##   Diogenidae                         0          2        0        0
##   Diploastraeidae                    0          0        0        3
##   Donacidae                          0          0        0        0
##   Dussumieriidae                     0          0        1        0
##   Dysideidae                         0          0        0        0
##   Echeneidae                         0          0        2        0
##   Engraulidae                        0          0       17        0
##   Ephippidae                         0          0        4        0
##   Epialtidae                         0          2        0        0
##   Eriphiidae                         0          1        0        0
##   Euphylliidae                       0          0        0       14
##   Faviidae                           0          0        0        4
##   Fistulariidae                      0          0        1        0
##   Fungiidae                          0          0        0       22
##   Gerreidae                          0          0        3        0
##   Glyceridae                         1          0        0        0
##   Gobiesocidae                       0          0        1        0
##   Gobiidae                           0          0       35        0
##   Goniadidae                         3          0        0        0
##   Gorgoniidae                        0          0        0        1
##   Grapsidae                          0          1        0        0
##   Haemulidae                         0          0        2        0
##   Halichondriidae                    0          0        0        0
##   Haliotidae                         0          0        0        0
##   Helioporidae                       0          0        0        2
##   Hemiscylliidae                     0          0        4        0
##   Holocentridae                      0          0        6        0
##   Holothuriidae                      0          0        0        0
##   Hydrocharitaceae                   0          0        0        0
##   Labridae                           0          0       60        0
##   Leiognathidae                      0          0       13        0
##   Lethrinidae                        0          0        3        0
##   Leucosiidae                        0          1        0        0
##   Littorinidae                       0          0        0        0
##   Lobophylliidae                     0          0        0       24
##   Lutjanidae                         0          0       12        0
##   Maeridae                           0          3        0        0
##   Margaritidae                       0          0        0        0
##   Matutidae                          0          2        0        0
##   Melithaeidae                       0          0        0        1
##   Merulinidae                        0          0        0       54
##   Microdesmidae                      0          0       12        0
##   Milleporidae                       0          0        0        3
##   Monacanthidae                      0          0        6        0
##   Monodactylidae                     0          0        2        0
##   Montastraeidae                     0          0        0        1
##   Mugilidae                          0          0        3        0
##   Mullidae                           0          0       21        0
##   Muraenidae                         0          0        6        0
##   Muricidae                          0          0        0        0
##   Mycalidae                          0          0        0        0
##   Nacellidae                         0          0        0        0
##   Nassariidae                        0          0        0        0
##   Naticidae                          0          0        0        0
##   Nemipteridae                       0          0       42        0
##   Nephtheidae                        0          0        0        5
##   Neritidae                          0          0        0        0
##   Ocypodidae                         0          2        0        0
##   Ogcocephalidae                     0          0        1        0
##   Opheliidae                         1          0        0        0
##   Opistognathidae                    0          0        1        0
##   Orbiniidae                         1          0        0        0
##   Ostraciidae                        0          0        5        0
##   Ostreidae                          0          0        0        0
##   Paguridae                          0          1        0        0
##   Palaemonidae                       0          2        0        0
##   Paralichthyidae                    0          0        2        0
##   Pempheridae                        0          0       19        0
##   Phloeodictyidae                    0          0        0        0
##   Phyllidiidae                       0          0        0        0
##   Pilumnidae                         0          1        0        0
##   Pinguipedidae                      0          0        9        0
##   Pinnidae                           0          0        0        0
##   Platycephalidae                    0          0        3        0
##   Plerogyridae                       0          0        0       11
##   Plesiopidae                        0          0        2        0
##   Pocilloporidae                     0          0        0       17
##   Podoceridae                        0          1        0        0
##   Pomacanthidae                      0          0       19        0
##   Pomacentridae                      0          0      106        0
##   Poritidae                          0          0        0        8
##   Portunidae                         0          1        0        0
##   Potamididae                        0          0        0        0
##   Priacanthidae                      0          0        2        0
##   Psammocoridae                      0          0        0        5
##   Psettodidae                        0          0        1        0
##   Pseudochromidae                    0          0        4        0
##   Rachycentridae                     0          0        1        0
##   Rhincodontidae                     0          0        5        0
##   Rhynchocinetidae                   0          1        0        0
##   Sabellidae                         1          0        0        0
##   Samaridae                          0          0        9        0
##   Scaridae                           0          0       13        0
##   Scleractinia incertae sedis        0          0        0        9
##   Scombridae                         0          0        4        0
##   Scorpaenidae                       0          0       14        0
##   Serpulidae                         1          0        0        0
##   Serranidae                         0          0       25        0
##   Siganidae                          0          0        5        0
##   Sillaginidae                       0          0        1        0
##   Soleidae                           0          0        6        0
##   Sphyraenidae                       0          0        6        0
##   Spionidae                          5          0        0        0
##   Stichopodidae                      0          0        0        0
##   Strombidae                         0          0        0        0
##   Suberitidae                        0          0        0        0
##   Synanceiidae                       0          0        4        0
##   Synaptidae                         0          0        0        0
##   Syngnathidae                       0          0        3        0
##   Synodontidae                       0          0       14        0
##   Tegulidae                          0          0        0        0
##   Terapontidae                       0          0        2        0
##   Terebridae                         0          0        0        0
##   Tetillidae                         0          0        0        0
##   Tetraodontidae                     0          0       16        0
##   Triakidae                          0          0        1        0
##   Trichiuridae                       0          0        2        0
##   Tripterygiidae                     0          0       46        0
##   Trochidae                          0          0        0        0
##   Tryphosidae                        0          1        0        0
##   Tubiporidae                        0          0        0        1
##   Turbinidae                         0          0        0        0
##   Uranoscopidae                      0          0        2        0
##   Veneridae                          0          0        0        0
##   Volutidae                          0          0        0        0
##                              
##                               Echinodermata Mollusca Porifera Tracheophyta
##   Acanthasteridae                         1        0        0            0
##   Acanthogorgiidae                        0        0        0            0
##   Acanthuridae                            0        0        0            0
##   Acroporidae                             0        0        0            0
##   Agariciidae                             0        0        0            0
##   Aglaopheniidae                          0        0        0            0
##   Alcyoniidae                             0        0        0            0
##   Ancorinidae                             0        0        2            0
##   Apogonidae                              0        0        0            0
##   Arcidae                                 0        1        0            0
##   Ariommatidae                            0        0        0            0
##   Astrocoeniidae                          0        0        0            0
##   Astropectinidae                         1        0        0            0
##   Atherinidae                             0        0        0            0
##   Balistidae                              0        0        0            0
##   Belonidae                               0        0        0            0
##   Blenniidae                              0        0        0            0
##   Bopyridae                               0        0        0            0
##   Bothidae                                0        0        0            0
##   Caesionidae                             0        0        0            0
##   Calappidae                              0        0        0            0
##   Callionymidae                           0        0        0            0
##   Carangidae                              0        0        0            0
##   Carcharhinidae                          0        0        0            0
##   Centriscidae                            0        0        0            0
##   Centrolophidae                          0        0        0            0
##   Chaetodontidae                          0        0        0            0
##   Chalinidae                              0        0        2            0
##   Champsodontidae                         0        0        0            0
##   Cheloniidae                             0        0        0            0
##   Chilodontaidae                          0        1        0            0
##   Chirocentridae                          0        0        0            0
##   Cirratulidae                            0        0        0            0
##   Citharidae                              0        0        0            0
##   Clupeidae                               0        0        0            0
##   Conidae                                 0        2        0            0
##   Cymodoceaceae                           0        0        0            3
##   Cynoglossidae                           0        0        0            0
##   Cypraeidae                              0        6        0            0
##   Dactylopteridae                         0        0        0            0
##   Dasyatidae                              0        0        0            0
##   Dendrophylliidae                        0        0        0            0
##   Desmacellidae                           0        0        1            0
##   Diadematidae                            1        0        0            0
##   Diodontidae                             0        0        0            0
##   Diogenidae                              0        0        0            0
##   Diploastraeidae                         0        0        0            0
##   Donacidae                               0        2        0            0
##   Dussumieriidae                          0        0        0            0
##   Dysideidae                              0        0        1            0
##   Echeneidae                              0        0        0            0
##   Engraulidae                             0        0        0            0
##   Ephippidae                              0        0        0            0
##   Epialtidae                              0        0        0            0
##   Eriphiidae                              0        0        0            0
##   Euphylliidae                            0        0        0            0
##   Faviidae                                0        0        0            0
##   Fistulariidae                           0        0        0            0
##   Fungiidae                               0        0        0            0
##   Gerreidae                               0        0        0            0
##   Glyceridae                              0        0        0            0
##   Gobiesocidae                            0        0        0            0
##   Gobiidae                                0        0        0            0
##   Goniadidae                              0        0        0            0
##   Gorgoniidae                             0        0        0            0
##   Grapsidae                               0        0        0            0
##   Haemulidae                              0        0        0            0
##   Halichondriidae                         0        0        3            0
##   Haliotidae                              0        1        0            0
##   Helioporidae                            0        0        0            0
##   Hemiscylliidae                          0        0        0            0
##   Holocentridae                           0        0        0            0
##   Holothuriidae                          20        0        0            0
##   Hydrocharitaceae                        0        0        0           10
##   Labridae                                0        0        0            0
##   Leiognathidae                           0        0        0            0
##   Lethrinidae                             0        0        0            0
##   Leucosiidae                             0        0        0            0
##   Littorinidae                            0        4        0            0
##   Lobophylliidae                          0        0        0            0
##   Lutjanidae                              0        0        0            0
##   Maeridae                                0        0        0            0
##   Margaritidae                            0        1        0            0
##   Matutidae                               0        0        0            0
##   Melithaeidae                            0        0        0            0
##   Merulinidae                             0        0        0            0
##   Microdesmidae                           0        0        0            0
##   Milleporidae                            0        0        0            0
##   Monacanthidae                           0        0        0            0
##   Monodactylidae                          0        0        0            0
##   Montastraeidae                          0        0        0            0
##   Mugilidae                               0        0        0            0
##   Mullidae                                0        0        0            0
##   Muraenidae                              0        0        0            0
##   Muricidae                               0        4        0            0
##   Mycalidae                               0        0        1            0
##   Nacellidae                              0        1        0            0
##   Nassariidae                             0        1        0            0
##   Naticidae                               0        3        0            0
##   Nemipteridae                            0        0        0            0
##   Nephtheidae                             0        0        0            0
##   Neritidae                               0        5        0            0
##   Ocypodidae                              0        0        0            0
##   Ogcocephalidae                          0        0        0            0
##   Opheliidae                              0        0        0            0
##   Opistognathidae                         0        0        0            0
##   Orbiniidae                              0        0        0            0
##   Ostraciidae                             0        0        0            0
##   Ostreidae                               0        1        0            0
##   Paguridae                               0        0        0            0
##   Palaemonidae                            0        0        0            0
##   Paralichthyidae                         0        0        0            0
##   Pempheridae                             0        0        0            0
##   Phloeodictyidae                         0        0        1            0
##   Phyllidiidae                            0        2        0            0
##   Pilumnidae                              0        0        0            0
##   Pinguipedidae                           0        0        0            0
##   Pinnidae                                0        1        0            0
##   Platycephalidae                         0        0        0            0
##   Plerogyridae                            0        0        0            0
##   Plesiopidae                             0        0        0            0
##   Pocilloporidae                          0        0        0            0
##   Podoceridae                             0        0        0            0
##   Pomacanthidae                           0        0        0            0
##   Pomacentridae                           0        0        0            0
##   Poritidae                               0        0        0            0
##   Portunidae                              0        0        0            0
##   Potamididae                             0        2        0            0
##   Priacanthidae                           0        0        0            0
##   Psammocoridae                           0        0        0            0
##   Psettodidae                             0        0        0            0
##   Pseudochromidae                         0        0        0            0
##   Rachycentridae                          0        0        0            0
##   Rhincodontidae                          0        0        0            0
##   Rhynchocinetidae                        0        0        0            0
##   Sabellidae                              0        0        0            0
##   Samaridae                               0        0        0            0
##   Scaridae                                0        0        0            0
##   Scleractinia incertae sedis             0        0        0            0
##   Scombridae                              0        0        0            0
##   Scorpaenidae                            0        0        0            0
##   Serpulidae                              0        0        0            0
##   Serranidae                              0        0        0            0
##   Siganidae                               0        0        0            0
##   Sillaginidae                            0        0        0            0
##   Soleidae                                0        0        0            0
##   Sphyraenidae                            0        0        0            0
##   Spionidae                               0        0        0            0
##   Stichopodidae                          10        0        0            0
##   Strombidae                              0        3        0            0
##   Suberitidae                             0        0        3            0
##   Synanceiidae                            0        0        0            0
##   Synaptidae                              2        0        0            0
##   Syngnathidae                            0        0        0            0
##   Synodontidae                            0        0        0            0
##   Tegulidae                               0        1        0            0
##   Terapontidae                            0        0        0            0
##   Terebridae                              0        2        0            0
##   Tetillidae                              0        0        1            0
##   Tetraodontidae                          0        0        0            0
##   Triakidae                               0        0        0            0
##   Trichiuridae                            0        0        0            0
##   Tripterygiidae                          0        0        0            0
##   Trochidae                               0        4        0            0
##   Tryphosidae                             0        0        0            0
##   Tubiporidae                             0        0        0            0
##   Turbinidae                              0        2        0            0
##   Uranoscopidae                           0        0        0            0
##   Veneridae                               0        3        0            0
##   Volutidae                               0        1        0            0
Visualiser les occurrences en fonction du temps

Il est toujours intéressant de regarder la distribution temporelle des entrées de jeu de données. Afin de les visualiser, il nous faut une colonne contenant les années d’entrée des occurrences. Les occurrences téléchargées depuis le mappeur ou obtenus en utilisant {robis} ont une colonne nommée yearcollected. Si cette variable est inexistante dans votre jeu de données, il faut créer une colonne d année en récupérant l information depuis la colonne enventDates en utilisant la fonction d’analyse de date as.Date(), puis en l extrayant avec la fonction format(). N hésitez pas a utiliser ?as.Date ou ?format pour obtenir plus d information depuis l aide R:

table(islands$year)
## 
## 1899 1963 1965 1974 1977 1980 1989 1993 1997 1998 1999 2004 2005 2006 2007 2008 
##    1    1    1    1  115    2    1   82    1   35    3   13    1    3    1    6 
## 2009 2011 2012 2013 2014 
##    1    3   66  113    8

Le package {ggplot2} est un superbe outil de visualisation. Nous approfondirons notre voyage dans {ggplot2} plus loin dans ce chapitre. Pour le moment, vérifiez que vous avez bien installé le package puis lancez la commande ci-dessous pour produire un diagramme en barre montrant la distribution des occurrences au cours du temps:

ggplot() + 
 geom_bar(data = islands, stat = "count",aes(x = year, fill = phylum), binwidth = 5) +
 scale_fill_brewer(palette = "Paired") +
 theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
## Warning: Ignoring unknown parameters: binwidth

Liste de contrôle

La fonction checklist() renvoie tous les taxons observés pour un ensemble de filtres.

?checklist

checklist("Semelidae")
## Retrieved 108 records of approximately 108 (100%)

Tout comme la fonction occurrence(), la fonction checklist() accepte les géométries WKT:

checklist(geometry = "POLYGON ((2.59689 51.16772, 2.62436 51.14059, 2.76066 51.19225, 2.73216 51.20946, 2.59689 51.16772))")
## Retrieved 902 records of approximately 889 (100%)
Mesures ou faits associés

Le package donne également accès aux entrées MeasurementOrFact associées aux occurences. Pour inclure les données de MeasurementOrFact il faut paramétrer: mof = TRUE dans occurence().

occ <- occurrence("Abra tenuis", mof = TRUE)
## Retrieved 4249 records of approximately 4249 (100%)
View(occ)

Les données de MeasurementOrFact sont nichées dans occurrence, mais la fonction measurements() permet de les extraire vers leur propre data frame. Utilisez le paramètre fields = pour indiquer les champs d occurrence devant être conservés dans la table des mesures.

mof <- measurements(occ, fields = c("scientificName", "decimalLongitude", "decimalLatitude"))
View(mof)

Traitement des données d occurrence

Nous utiliserons le package {dplyr} pour manipuler les données d occurrence récupérées sur OBIS.

lag <- occurrence("Lagis")
## Retrieved 5000 records of approximately 27309 (18%) Retrieved 10000 records of
## approximately 27309 (36%) Retrieved 15000 records of approximately 27309 (54%)
## Retrieved 20000 records of approximately 27309 (73%) Retrieved 25000 records of
## approximately 27309 (91%) Retrieved 27309 records of approximately 27309 (100%)
map_leaflet(lag)
table(lag$species)
## 
## Lagis abranchiata   Lagis australis       Lagis bocki  Lagis crenulatus 
##                 6                55                85                 1 
##      Lagis koreni Lagis neapolitana  Lagis plurihamus      Lagis portus 
##             27092                11                 1                 1
Filtrer

La fonction filter() peut être utilisée pour filtrer les occurrences en se basant sur une ou plusieurs propriétés. Par exemple, pour garder uniquement les occurrences de Lagis australis:

lagaus <- lag %>% filter(species == "Lagis australis")

map_leaflet(lagaus)
str(lag)
## tibble [27,309 x 127] (S3: tbl_df/tbl/data.frame)
##  $ date_year                    : int [1:27309] 1992 1988 2000 1990 1983 1980 1982 2001 1996 1990 ...
##  $ scientificNameID             : chr [1:27309] "urn:lsid:marinespecies.org:taxname:152367" "urn:lsid:marinespecies.org:taxname:152367" "urn:lsid:marinespecies.org:taxname:130595" "urn:lsid:marinespecies.org:taxname:152367" ...
##  $ year                         : chr [1:27309] "1992" "1988" "2000" "1990" ...
##  $ scientificName               : chr [1:27309] "Lagis koreni" "Lagis koreni" "Lagis koreni" "Lagis koreni" ...
##  $ individualCount              : chr [1:27309] "1.0" NA "1.0" "1.0" ...
##  $ dropped                      : logi [1:27309] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ aphiaID                      : int [1:27309] 152367 152367 152367 152367 152367 152367 152367 152367 152367 152367 ...
##  $ decimalLatitude              : num [1:27309] 56.1 53.9 51.1 55.7 56.1 ...
##  $ subclassid                   : int [1:27309] 754175 754175 754175 754175 754175 754175 754175 754175 754175 754175 ...
##  $ phylumid                     : int [1:27309] 882 882 882 882 882 882 882 882 882 882 ...
##  $ familyid                     : int [1:27309] 980 980 980 980 980 980 980 980 980 980 ...
##  $ catalogNumber                : chr [1:27309] "AarhusUniversity_zoobenthos_257442" "NATENG000027_435_152367" "16040" "AarhusUniversity_zoobenthos_583253" ...
##  $ occurrenceStatus             : chr [1:27309] "present" "present" "present" "present" ...
##  $ basisOfRecord                : chr [1:27309] "Occurrence" "HumanObservation" "Occurrence" "Occurrence" ...
##  $ terrestrial                  : logi [1:27309] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ modified                     : chr [1:27309] "2015-07-22 14:03:01" "2014-08-13 00:00:00" "2012-01-16 16:13:56" "2015-07-22 14:03:01" ...
##  $ maximumDepthInMeters         : num [1:27309] 14 NA NA 7.6 13.5 24 7 NA 27.2 16.2 ...
##  $ id                           : chr [1:27309] "000082d2-dd7e-4cdd-b277-70f8eb97a484" "0002e55a-5103-482e-9e4e-aa04de4f566d" "00067815-d4e4-4f4b-b6f9-7d457b5c85cd" "0007c5aa-b2a7-4f06-8de0-abab9632bf25" ...
##  $ day                          : chr [1:27309] "10" "26" NA "27" ...
##  $ order                        : chr [1:27309] "Terebellida" "Terebellida" "Terebellida" "Terebellida" ...
##  $ dataset_id                   : chr [1:27309] "ec9df3b9-3b2b-4d83-881b-27bcbcd57b95" "0c1cb7e9-c7d1-4643-b245-daa8839a183f" "4b615c83-2350-47e7-ad7f-7c4759d3baf9" "ec9df3b9-3b2b-4d83-881b-27bcbcd57b95" ...
##  $ locality                     : chr [1:27309] "170084" NA "Kustbanken" "42740" ...
##  $ decimalLongitude             : num [1:27309] 10.25 -3.11 2.53 9.67 10.25 ...
##  $ collectionCode               : chr [1:27309] "Time series of zoobenthos in Danish waters" "The Marine Biological Association of the United Kingdom" "Macrobel" "Time series of zoobenthos in Danish waters" ...
##  $ date_end                     : num [1:27309] 7.24e+11 5.89e+11 9.54e+11 6.36e+11 4.34e+11 ...
##  $ speciesid                    : int [1:27309] 152367 152367 152367 152367 152367 152367 152367 152367 152367 152367 ...
##  $ occurrenceID                 : chr [1:27309] "AarhusUniversity_zoobenthos_257442" "DASSH_NATENG000027_435_152367" "urn:catalog:UGent:Macrobel:16040" "AarhusUniversity_zoobenthos_583253" ...
##  $ suborderid                   : int [1:27309] 152292 152292 152292 152292 152292 152292 152292 152292 152292 152292 ...
##  $ date_start                   : num [1:27309] 7.24e+11 5.89e+11 9.52e+11 6.36e+11 4.34e+11 ...
##  $ month                        : chr [1:27309] "12" "8" "3" "2" ...
##  $ genus                        : chr [1:27309] "Lagis" "Lagis" "Lagis" "Lagis" ...
##  $ samplingProtocol             : chr [1:27309] "Benthos Samplers" "Sampling instrument: 50: Sediment Grab" NA "Benthos Samplers" ...
##  $ eventDate                    : chr [1:27309] "1992-12-10" "1988-08-26" "2000-03" "1990-02-27" ...
##  $ eventID                      : chr [1:27309] "67307" "NATENG000027_435" NA "45719" ...
##  $ brackish                     : logi [1:27309] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ absence                      : logi [1:27309] FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ samplingEffort               : chr [1:27309] "0,0123 m²" "1.000m2" "0.1026 m²" "0,0123 m²" ...
##  $ genusid                      : int [1:27309] 152365 152365 152365 152365 152365 152365 152365 152365 152365 152365 ...
##  $ originalScientificName       : chr [1:27309] "Pectinaria koreni" "Pectinaria koreni" "Pectinaria (Lagis) koreni" "Pectinaria koreni" ...
##  $ marine                       : logi [1:27309] TRUE TRUE TRUE TRUE TRUE TRUE ...
##  $ minimumDepthInMeters         : num [1:27309] 14 NA NA 7.6 13.5 24 7 NA 27.2 16.2 ...
##  $ infraclassid                 : int [1:27309] 154974 154974 154974 154974 154974 154974 154974 154974 154974 154974 ...
##  $ institutionCode              : chr [1:27309] "Aarhus University, Department of Bioscience, Marine Ecology Roskilde" "Marine Biological Association of the UK (MBA)" "UGent" "Aarhus University, Department of Bioscience, Marine Ecology Roskilde" ...
##  $ date_mid                     : num [1:27309] 7.24e+11 5.89e+11 9.53e+11 6.36e+11 4.34e+11 ...
##  $ infraclass                   : chr [1:27309] "Canalipalpata" "Canalipalpata" "Canalipalpata" "Canalipalpata" ...
##  $ class                        : chr [1:27309] "Polychaeta" "Polychaeta" "Polychaeta" "Polychaeta" ...
##  $ suborder                     : chr [1:27309] "Terebelliformia" "Terebelliformia" "Terebelliformia" "Terebelliformia" ...
##  $ orderid                      : int [1:27309] 900 900 900 900 900 900 900 900 900 900 ...
##  $ sex                          : chr [1:27309] "U" NA NA "U" ...
##  $ geodeticDatum                : chr [1:27309] "EPSG:4326" "EPSG:4326" "EPSG:4326" "EPSG:4326" ...
##  $ kingdom                      : chr [1:27309] "Animalia" "Animalia" "Animalia" "Animalia" ...
##  $ classid                      : int [1:27309] 883 883 883 883 883 883 883 883 883 883 ...
##  $ phylum                       : chr [1:27309] "Annelida" "Annelida" "Annelida" "Annelida" ...
##  $ lifeStage                    : chr [1:27309] "U" NA "Adult" "U" ...
##  $ species                      : chr [1:27309] "Lagis koreni" "Lagis koreni" "Lagis koreni" "Lagis koreni" ...
##  $ subclass                     : chr [1:27309] "Sedentaria" "Sedentaria" "Sedentaria" "Sedentaria" ...
##  $ datasetID                    : chr [1:27309] "IMIS:dasid:4494" "IMIS:dasid:5247" "IMIS:dasid:145" "IMIS:dasid:4494" ...
##  $ family                       : chr [1:27309] "Pectinariidae" "Pectinariidae" "Pectinariidae" "Pectinariidae" ...
##  $ kingdomid                    : int [1:27309] 2 2 2 2 2 2 2 2 2 2 ...
##  $ node_id                      : chr [1:27309] "4bf79a01-65a9-4db6-b37b-18434f26ddfc" "4bf79a01-65a9-4db6-b37b-18434f26ddfc,f92d5d7f-47a6-4605-9fd0-a8538dfde3fd" "4bf79a01-65a9-4db6-b37b-18434f26ddfc" "4bf79a01-65a9-4db6-b37b-18434f26ddfc" ...
##  $ sss                          : num [1:27309] 18 33.1 33.5 17.3 18.1 ...
##  $ depth                        : num [1:27309] 14 NA NA 7.6 13.5 24 7 NA 27.2 16.2 ...
##  $ shoredistance                : int [1:27309] 856 4466 5425 596 1015 952 5583 8459 3717 2779 ...
##  $ sst                          : num [1:27309] 10.1 11.3 12.5 10 10.2 ...
##  $ bathymetry                   : num [1:27309] 12.4 42.2 15 7.8 13.6 21.8 -1 27 25.8 16.8 ...
##  $ continent                    : chr [1:27309] NA "North East Atlantic" "North Sea" NA ...
##  $ preparations                 : chr [1:27309] NA "Unknown" NA NA ...
##  $ flags                        : chr [1:27309] NA "no_depth" "no_depth" NA ...
##  $ country                      : chr [1:27309] NA NA "Belgium" NA ...
##  $ references                   : chr [1:27309] NA NA "http://www.vliz.be/vmdcdata/macrobel/aphia.php?p=taxdetails&id=130595" NA ...
##  $ dynamicProperties            : chr [1:27309] NA NA "SampleSize=0.1026 m²;" NA ...
##  $ fieldNumber                  : chr [1:27309] NA NA "847_1" NA ...
##  $ bibliographicCitation        : chr [1:27309] NA NA "Degraer, S.; Wittoeck, J.; Appeltans, W.; Cooreman, K.; Deprez, T.; Hillewaert, H.; Hostens, K.; Mees, J.; Vand"| __truncated__ NA ...
##  $ scientificNameAuthorship     : chr [1:27309] NA NA "(Malmgren, 1866)" NA ...
##  $ specificEpithet              : chr [1:27309] NA NA "koreni" NA ...
##  $ recordedBy                   : chr [1:27309] NA NA "Degraer Steven" NA ...
##  $ language                     : chr [1:27309] NA NA NA NA ...
##  $ footprintSRS                 : chr [1:27309] NA NA NA NA ...
##  $ coordinateUncertaintyInMeters: chr [1:27309] NA NA NA NA ...
##  $ eventRemarks                 : chr [1:27309] NA NA NA NA ...
##  $ datasetName                  : chr [1:27309] NA NA NA NA ...
##  $ county                       : chr [1:27309] NA NA NA NA ...
##  $ stateProvince                : chr [1:27309] NA NA NA NA ...
##  $ eventTime                    : chr [1:27309] NA NA NA NA ...
##  $ occurrenceRemarks            : chr [1:27309] NA NA NA NA ...
##  $ parentEventID                : chr [1:27309] NA NA NA NA ...
##  $ footprintWKT                 : chr [1:27309] NA NA NA NA ...
##  $ locationID                   : chr [1:27309] NA NA NA NA ...
##  $ identifiedBy                 : chr [1:27309] NA NA NA NA ...
##  $ recordNumber                 : chr [1:27309] NA NA NA NA ...
##  $ otherCatalogNumbers          : chr [1:27309] NA NA NA NA ...
##  $ identificationQualifier      : chr [1:27309] NA NA NA NA ...
##  $ waterBody                    : chr [1:27309] NA NA NA NA ...
##  $ georeferenceRemarks          : chr [1:27309] NA NA NA NA ...
##  $ taxonRank                    : chr [1:27309] NA NA NA NA ...
##  $ dateIdentified               : chr [1:27309] NA NA NA NA ...
##  $ verbatimDepth                : chr [1:27309] NA NA NA NA ...
##  $ habitat                      : chr [1:27309] NA NA NA NA ...
##  $ taxonRemarks                 : chr [1:27309] NA NA NA NA ...
##   [list output truncated]

Remarquez l opérateur pipe %>% (https://juba.github.io/tidyverse/10-dplyr.html, section 10.3). Avec le pipe l’ordre des opérations correspond à l’ordre naturel de leur exécution, et on n’a pas besoin de créer d’objet intermédiaire ou d emboîter plusieurs fonctions les unes dans les autres (peu lisible).

Voici un autre exemple où seules les occurrences appartenant aux jeux de données du RSMP Baseline Dataset sont sélectionnées:

rsmp <- lag %>% filter(grepl("RSMP Baseline Dataset", datasetName))

# grepl is used for matching strings

map_leaflet(rsmp)

Notez que le champ MeasurementOrFact peut être utilisé comme paramètres de la fonction occurrence. Par exemple, nous obtenir uniquement les occurrences avec des mesures de biomasses associées:

occurrence("Abra tenuis", mof = TRUE, measurementtype = "biomass") %>%
  measurements()
## Retrieved 15 records of approximately 15 (100%)
Sélectionner des colonnes

La fonction select() sélectionne ou désélectionne des colonnes. Pour sélectionner uniquement les champs decimalLongitude et decimalLatitude:

lagaus %>% select(decimalLongitude, decimalLatitude)

A partir de ce résultat, des coordonnées distintes peuvent être obtenues en utilisant la fonction distinct():

lagaus %>% select(decimalLongitude, decimalLatitude) %>% distinct()

En simplifiant:

lagaus %>% distinct(decimalLongitude, decimalLatitude)

Dans l exemple suivant les colonnes decimalLongitude et decimalLatitude sont également sélectionnées, mais en vérifiant les colonnes dont le noms commence par decimal:

lagaus %>% select(starts_with("decimal"))

Pour supprimer une colonne, il suffit d ajouter le signe moins devant le nom de la colonne.

Summarizing, en français dans le texte

Pour regrouper les données et créer un résumé de statistiques descriptives, on peut utiliser les fonctions group_by() and summarize(). Pour regrouper les occurrences par espèces puis compter le nombre d’entrées par groupe et calculer les latitudes et longitudes min, max and median:

lag %>%
  group_by(species) %>%
  summarize(
    records = n(),
    medlon = round(median(decimalLongitude)),
    medlat = round(median(decimalLatitude)),
    minlon = round(min(decimalLongitude)),
    maxlon = round(max(decimalLongitude)),
    minlat = round(min(decimalLatitude)),
    maxlat = round(max(decimalLatitude))
  )
Trier

La fonction arrange() permet de trier les données. Les noms de colonnes peuvent être compilés dans desc() pour les trier dans l ordre décroissant. Ici on montre 1- les plus récents et 2- les plus vieux enregistrements de jeux de données de Lagis:

head(lag %>% arrange(eventDate)) %>% select(eventDate, decimalLongitude, decimalLatitude, datasetName)
head(lag %>% arrange(desc(eventDate))) %>% select(eventDate, decimalLongitude, decimalLatitude, datasetName)
Muter

mutate() est utilisé pour ajouter une colonne. Pour ajouter une colonne d année basée sur eventDate:

lag_withyear <-lag %>% mutate(year = format(as.Date(eventDate), "%Y")) 
head(lag_withyear)